// pages/my/my.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    current: 0,

  },
  
  bindSwiper(e) {
    this.setData({
      current: e.detail.current
    })
  },

  bindUsetInfo(e) {
    const that = this;
    if (e.detail.userInfo) {
      that.setData({
        userInfo: e.detail.userInfo
      })
      app.globalData.userInfo = e.detail.userInfo;
      wx.request({
        url: app.globalData.url + 'Obtain',
        data: {
          openid: app.globalData.openid,
          wx_name: app.globalData.userInfo.nickName,
          wx_img: app.globalData.userInfo.avatarUrl,
        },
        method: 'POST',
        success: function (res) {
          that.bindMyself()
        },
      })
    }
  },

  navTo(e) {
    wx.navigateTo({
      url: e.currentTarget.dataset.url,
    })
  },

  goXingle(e) {
    wx.navigateToMiniProgram({
      appId: 'wxe19acbd2bd856b38',
    })
  },

  bindMyself(e) {
    const that = this;
    wx.showLoading({
      title: '玩命加载中',
      mask: true,
    })
    wx.request({
      url: app.globalData.url + 'Myself',
      method: 'POST',
      data: {
        uid:app.globalData.uid,
      },
      success: function (res) {
        if (res.data.info) {
          that.setData({
            myself : res.data.info,
          })
        }
        wx.hideLoading()
      },
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    const that = this
    let system = app.globalData.system;
    that.setData({
      system,
    })
    that.bindMyself();
    wx.stopPullDownRefresh();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.onLoad();
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})